package com.sikaryofficial.backend.constant;

import cn.hutool.core.text.CharSequenceUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author : qinjinyuan
 * @desc : 邮件发送者
 * @date : 2023/11/04 10:08
 */
@Getter
@AllArgsConstructor
public enum EmailSendSourceEnum {
    /**
     * 正常发送
     */
    NORMAL(EmailConstant.NORMAL_SENDER, "正常发送"),
    /**
     * gmail发送者
     */
    GMAIL(EmailConstant.GMAIL_SENDER, "gmail发送者"),
    ;
    private final String sendSource;
    private final String name;

    /**
     * 默认正常发送
     * @param sendSourceInput
     * @return
     */
    public static String getSendSourceByCode(String sendSourceInput) {
        return Arrays.stream(EmailSendSourceEnum.values())
                .filter(pointRuleEnum -> CharSequenceUtil.equals(pointRuleEnum.getSendSource(), sendSourceInput))
                .findFirst().orElse(NORMAL).getSendSource();
    }
}
